package com.thread.thread01;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @version: java version 23
 * @Author: 韩学新
 * @description:
 * @date: 2025-03-24 下午8:12
 */
public class Thread2 {
    public static void main() throws ExecutionException, InterruptedException {

        ThreadCallable threadCallable = new ThreadCallable();
        FutureTask<Integer> futureTask = new FutureTask<>(threadCallable);
        new Thread(futureTask).start();
        //主线程阻塞 ，LockSupport.park（），需要等待子线程执行完毕，调用LockSupport.parkNanos（）唤醒主线程，拿到子线程返回结果
        Integer integer = futureTask.get();
        System.out.println(Thread.currentThread().getName() + "，" + integer);


    }

}
